home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / intronet.c < prev    next >
C/C++ Source or Header  |  1996-02-23  |  9KB  |  258 lines

  1. #include "c:\netnow\hmistd.h"
  2. #include "c:\netnow\netnow.h"
  3. #include "c:\netnow\vdata.h"
  4. #include "c:\netnow\vchat.h"
  5. //#include "digi.h"
  6. #include "cgdv.h"
  7. #include "c:\sos\include\sosm.h"
  8.  
  9.  
  10. #define    YES                    1
  11. #define    NO                        0
  12. #define    FRIENDLY                0
  13. #define    LEAGUE                1
  14. #define    CUP                    2
  15. #define    PRACTICE                3
  16. #define    NETWORK                4
  17.  
  18. extern     int    x1ok;    
  19. extern     int    y1ok;    
  20. extern     int    x2ok;
  21. extern     int    y2ok;    
  22. extern     int    bitaccept; 
  23.  
  24. extern     volatile int Team_A,Team_B;
  25. extern      unsigned short joy1_cnt_x,joy1_cnt_y;
  26. extern      unsigned short joy2_cnt_x,joy2_cnt_y;
  27. extern    int joy1_max_x,joy1_max_y,joy1_min_x,joy1_min_y;
  28. extern    int joy2_max_x,joy2_max_y,joy2_min_x,joy2_min_y;
  29.  
  30. short        DIGIdrvh;
  31.  
  32. char        calibrate_flag;
  33. unsigned short max_x;
  34. unsigned short min_x;
  35. unsigned short max_y;
  36. unsigned short min_y;
  37. int    slide_x;    
  38. int    slide_y;    
  39. char    print_joy_message,print_red_message;
  40.  
  41. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  42. //∫                                                                                                                              ∫
  43. //∫  Checks to see if network is on and if so allows NETWORK option to appear as a competition type.                             ∫
  44. //∫                                                                                                                                              ∫
  45. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  46.  
  47. int    CheckFORnet()
  48. {
  49.         if ( ( hmiNETNOWInitSystem( 16 ) != _NETNOW_NO_ERROR) )
  50.             return    (NETWORK-1);
  51.         else
  52.             return    (NETWORK);
  53.  
  54. }
  55.  
  56. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  57. //∫                                                                                                                              ∫
  58. //∫  Deinitialises netstuff if it was previously initialised...                                                                  ∫
  59. //∫                                                                                                                                              ∫
  60. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  61.  
  62. void    DeinitialiseNET(int netflag)
  63. {
  64.         if (netflag==NETWORK)
  65.             hmiNETNOWUnInitSystem();
  66. }
  67.  
  68.  
  69. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  70. //∫                                                                                                                              ∫
  71. //∫  Sets up variables indicating that network game is to begin....                                                              ∫
  72. //∫                                                                                                                                              ∫
  73. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  74.  
  75. void    Init_Network_Game()
  76. {
  77.     Start_Network_Game();
  78.  
  79.  
  80.  
  81. //    printf("Initialises Team_A, Team_B, TeamChoice & PlayerChoice and starts network\n");
  82. }
  83.  
  84. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  85. //∫                                                                                                                              ∫
  86. //∫  Tells network which two countries are to take part in netgame...                                                            ∫
  87. //∫                                                                                                                                              ∫
  88. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  89.  
  90. void    SendNETTeamInfo()
  91. {
  92.      SendTeamInfo();
  93. //    printf("\nTeam %d plays team %d\n",Team_A,Team_B);
  94. }
  95.  
  96.  
  97. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  98. //∫                                                                                                                              ∫
  99. //∫  Short delay before any more netinfo can be sent...                                                                          ∫
  100. //∫                                                                                                                                              ∫
  101. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  102.  
  103. void    TickerPause()
  104. {
  105. //        printf("ticker....delay\n");
  106.         TickPause();
  107. }
  108.  
  109.  
  110. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  111. //∫                                                                                                                              ∫
  112. //∫  Send data indicating which player user is to control....                                                                    ∫
  113. //∫                                                                                                                                              ∫
  114. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  115.  
  116. void    SendPlayerChoice()
  117. {
  118.                 SendPlayerInfo();
  119. }
  120.  
  121. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  122. //∫                                                                                                                              ∫
  123. //∫  All users have selected teams and players....                                                                               ∫
  124. //∫                                                                                                                                              ∫
  125. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  126. //
  127. //void    SendNetOKAY()
  128. //{
  129. //                SendNetDone();
  130. //}
  131. //
  132. //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  133. //∫                                                                                                                              ∫
  134. //∫  Polls all network machines....                                                                                              ∫
  135. //∫                                                                                                                                              ∫
  136. //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  137. //
  138. //int Polling_Network()
  139. //{
  140. //            return    (Poll_Network());
  141. //}
  142.  
  143.  
  144.  
  145. void    InitCalibration(int j)
  146. {
  147.             max_x                =    0;        
  148.             min_x                =    65535;
  149.             max_y                =    0;
  150.             min_y                =    65535;
  151.             calibrate_flag    =    NULL;
  152.             print_joy_message    =    1; 
  153.  
  154.             x1ok       = 1;    
  155.             y1ok       = 2;    
  156.             x2ok       = 4;    
  157.             y2ok       = 8;    
  158.             bitaccept = x1ok+y1ok+x2ok+y2ok;
  159. }
  160.  
  161.  
  162. void    CalibrateJoy(int j)    
  163. {
  164.         unsigned    short x,y;
  165.         unsigned char butt;
  166.  
  167. //        x1ok            =    1;      
  168. //        y1ok            =    2;      
  169. //        x2ok            =    4;      
  170. //        y2ok            =    8;      
  171. //        bitaccept    =    15;  
  172.  
  173.         if (calibrate_flag==2 || calibrate_flag==3)
  174.         {
  175.             if (!j)
  176.                     read_joystick(0,&joy1_cnt_x,&joy1_cnt_y,&butt);
  177.             else
  178.                     read_joystick(1,&joy2_cnt_x,&joy2_cnt_y,&butt);
  179.         }
  180.  
  181.  
  182.  
  183.  
  184.         
  185.         if (calibrate_flag==3 && ( butt & 3)!=0 )
  186.         {
  187.  
  188. //            if (!j)
  189. //                {
  190. //                    joy1_cnt_x    =    x;
  191. //                    joy1_cnt_y    =    y;
  192. //                }                
  193. //            else
  194. //                {
  195. //                    joy2_cnt_x    =    x;
  196. //                    joy2_cnt_y    =    y;
  197. //                }                
  198. //            
  199.                 print_joy_message    =    1; 
  200.                  calibrate_flag        =    8;        //255;
  201.         }
  202.     
  203.  
  204.         if (calibrate_flag==2 && ( butt & 3)==0 )
  205.                  calibrate_flag        =    3;
  206.  
  207.         if (calibrate_flag==NULL)
  208.                 calibrate_flag++;
  209.  
  210.         if (calibrate_flag==1)
  211.         {    
  212.             read_joystick(j,&x,&y,&butt);
  213.  
  214.             if (x>max_x)
  215.                 max_x    =    x;
  216.             if (x<min_x)
  217.                 min_x    =    x;
  218.             if (y>max_y)
  219.                 max_y    =    y;
  220.             if (y<min_y)
  221.                 min_y    =    y;
  222.  
  223.             if ( ( butt & 3)!=0 )
  224.             {
  225.                 print_joy_message    =    1; 
  226.                 calibrate_flag        =    2;
  227.  
  228.                     if (!j)
  229.                     {
  230.                         joy1_max_x=max_x;
  231.                         joy1_max_y=max_y;
  232.                         joy1_min_x=min_x;
  233.                         joy1_min_y=min_y;
  234.                     }
  235.                             else
  236.                     {
  237.                         joy2_max_x    =    max_x;
  238.                         joy2_max_y    =    max_y;
  239.                         joy2_min_x    =    min_x;
  240.                         joy2_min_y    =    min_y;
  241.                     }
  242.             }
  243.         }
  244. }
  245.  
  246.  
  247. //void    setdigivar(short handle)
  248. //{
  249. //        DIGIdrvh        =    handle;     
  250. //}
  251. //
  252. //void    PLAYgdv()
  253. //{
  254. //    char    *GDV_MEMORY;
  255. //    GDV_MEMORY = (BYTE *) malloc( GDV_MEM );  
  256. //    cgdv("swhole_s.gdv",PL_SOUND,GDV_MEMORY);
  257. //}
  258.